# Contributor: Carlo Landmeter <clandmeter@gmail.com>
# Maintainer: Francesco Colista <francesco.colista@gmail.com>
pkgname=minidlna
pkgver=1.2.1
pkgrel=1
pkgdesc="A small dlna server"
url="https://sourceforge.net/projects/minidlna/"
arch="all"
license="GPL"
makedepends="
	bsd-compat-headers
	libvorbis-dev
	libogg-dev
	libid3tag-dev
	libexif-dev
	libjpeg-turbo-dev
	sqlite-dev
	ffmpeg-dev
	flac-dev
	"
install="minidlna.pre-install minidlna.post-upgrade"
subpackages="$pkgname-doc"
pkgusers="$pkgname"
pkggroups="$pkgname"
source="https://downloads.sourceforge.net/project/minidlna/minidlna/$pkgver/minidlna-$pkgver.tar.gz
	$pkgname.initd
	$pkgname.confd
	10-minidlna-nfo.patch"

builddir="$srcdir/$pkgname-$pkgver"

build() {
	cd "$builddir"
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--with-os-name="Alpine Linux" \
		--with-db-path=/var/lib/minidlna \
		--with-log-path=/var/log/minidlna
	make
}

check() {
	cd "$builddir"
	make check
}

package() {
	cd "$builddir"
	make DESTDIR="$pkgdir" install
	install -dm750 -o $pkgusers -g $pkggroups \
		"$pkgdir/var/lib/$pkgname" \
		"$pkgdir/var/log/$pkgname"
	install -m755 -D "$srcdir/$pkgname.initd" \
		"$pkgdir/etc/init.d/$pkgname"
	install -m644 -D "$srcdir/$pkgname.confd" \
		"$pkgdir/etc/conf.d/$pkgname"
	install -m644 -D "$pkgname.conf" \
		"$pkgdir"/etc/$pkgname.conf
	install -Dm644 "$srcdir"/$pkgname-$pkgver/minidlna.conf.5 \
		"$pkgdir"/usr/share/man/man5/minidlna.conf.5
	install -Dm644 "$srcdir"/$pkgname-$pkgver/minidlnad.8 \
		"$pkgdir"/usr/share/man/man8/minidlnad.8
}

sha512sums="17827155bfbfd2b51939bc86080e8724dcded138af8fede9c7715c225524e86d3c21bfd8d40dbf201861ef154189d9c5e223b719bf7695251212b26ec290462b  minidlna-1.2.1.tar.gz
e16961bb68c004297f1e26422b1d15bd8583ba2e0e36c88902a45573b685993fff88d2d0dae8c624eaeddb0deca614dbc13b8345f34b4c348961c00b05c0df30  minidlna.initd
e209848af0d79069ac989ad61d3be610b4c0c2783a207a50463a25ec3811b04d1da3a2acde54749878bec44e1567874ede827b978d5472c00f6a855663e5cbf8  minidlna.confd
59a97ef0a36d3ae44dd2e182a0b106f84ce5c17e7dc14ee0459b17430b57ddc59a74e8e67fc0a90326fa451a505b97a0b719b438475efac144028dd012b44af1  10-minidlna-nfo.patch"
